package com.declare.ajax;

import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/contentServlet")
public class contentServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String val = request.getParameter("id");
        List list = new ArrayList();
        if(val.equals("1")){
            list.add("10r");
            list.add("20r");
        }else if(val.equals("2")){
            list.add("5r");
            list.add("10r");
        }else if(val.equals("3")){
            list.add("15r");
            list.add("25r");
        }else if(val.equals("4")) {
            list.add("5r");
            list.add("10r");
        }
        String json = JSON.toJSONString(list);
        response.getWriter().println(json);
    }
}
